package org.flexlancer.databases
{
	public class Customers
	{
		public static const TABLE:String = "customers";

		public static function Add(contactnumber:String,name:String,area:String,address:String):void{
			try{
				var insertObj:Object = new Object();
				insertObj.name = name;
				insertObj.telephone = contactnumber;
				insertObj.address = address;
				insertObj.area = area;
				DatabaseManager.Manager.Insert(TABLE,insertObj);
			}catch(err:Error){
				throw err;
			}
		}

		public static function List(condition:String = ""):Array{
			try{
				return DatabaseManager.Manager.Select(TABLE,null,condition);
			}catch(err:Error){
				throw err;
			}
			return new Array;
		}
		public static function Update(contactnumber:String,name:String,area:String,address:String):void{
			try{
				var insertObj:Object = new Object();
				insertObj.name = name;
				insertObj.address = address;
				insertObj.area = area;
				DatabaseManager.Manager.Update(TABLE,insertObj,"telephone LIKE '"+contactnumber+"'");
			}catch(err:Error){
				throw err;
			}
		}
		public static function ContactNumbers(condition:String = ""):Array{
			try{
				var retValue:Array = new Array();
				for each ( var singlecust:Object in DatabaseManager.Manager.Select(TABLE,null,condition)){
					retValue.push(singlecust.telephone);
				}
				return retValue;
			}catch(err:Error){
				throw err;
			}
			return new Array;
		}
	}
}